package Reeks5.VanRansbeeck.Kevin.Util;

import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Botnamen {
    private List<String> botnamen;
    
    public Botnamen() {
        this.botnamen = new ArrayList<String>();
        try {
            InputStream inputStream = ClassLoader.getSystemResourceAsStream("txt/bots.txt");
            Scanner scan = 
                    new Scanner(inputStream);
            
            while(scan.hasNext()) {
                botnamen.add(scan.nextLine());
            }
        } catch (Exception ex) {
            Logger.getLogger(Botnamen.class.getName()).log(Level.SEVERE, null, ex);
            Logger.getLogger(Botnamen.class.getName()).log(Level.SEVERE, new File(".").getAbsolutePath());
        }
        
        //System.out.println(botnamen);
    }
    public String randomNaam() {
        String naam = "";
        Random r = new Random();
        try {
            naam = botnamen.get(r.nextInt(botnamen.size()));
            botnamen.remove(naam);
        } catch(Exception e) {
            naam = "***";
        } finally {
            return naam;
        }
    }
}
